home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_008 / src / hack.do.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  18KB  |  752 lines

  1. /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
  2. /* hack.do.c version 1.0.1 - check Levitation with POT_PARALYSIS
  3.                - added flags.no_rest_on_space */
  4.  
  5. #include <stdio.h>
  6. #ifndef AMIGA
  7. #include <signal.h>    /* Is this really used??? */
  8. #endif
  9. #include <fcntl.h>
  10. #include "hack.h"
  11. #include "def.func_tab.h"
  12.  
  13. extern char *getenv(),*parse(),*getlogin(),*lowc(),*unctrl();
  14. extern int float_down();
  15. extern char *nomovemsg, *catmore;
  16. extern struct obj *splitobj(), *addinv();
  17. extern boolean hmon();
  18. extern char morc;
  19.  
  20. /*   Routines to do various user commands */
  21.  
  22. int done1();
  23.  
  24. dodrink() {
  25.    register struct obj *otmp,*objs;
  26.    register struct monst *mtmp;
  27.    register int unkn = 0, nothing = 0;
  28.  
  29.    otmp = getobj("!", "drink");
  30.    if(!otmp) return(0);
  31.    switch(otmp->otyp){
  32.    case POT_RESTORE_STRENGTH:
  33.       unkn++;
  34.       pline("Wow!  This makes you feel great!");
  35.       if(u.ustr < u.ustrmax) {
  36.          u.ustr = u.ustrmax;
  37.          flags.botl = 1;
  38.       }
  39.       break;
  40.    case POT_BOOZE:
  41.       unkn++;
  42.       pline("Ooph!  This tastes like liquid fire!");
  43.       Confusion += d(3,8);
  44.       /* the whiskey makes us feel better */
  45.       if(u.uhp < u.uhpmax) losehp(-1, "bottle of whiskey");
  46.       if(!rn2(4)) {
  47.          pline("You pass out.");
  48.          multi = -rnd(15);
  49.          nomovemsg = "You awake with a headache.";
  50.       }
  51.       break;
  52.    case POT_INVISIBILITY:
  53.       if(Invis)
  54.         nothing++;
  55.       else {
  56.         if(!Blind)
  57.           pline("Gee!  All of a sudden, you can't see yourself.");
  58.         else
  59.           pline("You feel rather airy."), unkn++;
  60.         newsym(u.ux,u.uy);
  61.       }
  62.       Invis += rn1(15,31);
  63.       break;
  64.    case POT_FRUIT_JUICE:
  65.       pline("This tastes like fruit juice.");
  66.       lesshungry(20);
  67.       break;
  68.    case POT_HEALING:
  69.       pline("You begin to feel better.");
  70.       flags.botl = 1;
  71.       u.uhp += rnd(10);
  72.       if(u.uhp > u.uhpmax)
  73.          u.uhp = ++u.uhpmax;
  74.       if(Blind) Blind = 1;   /* see on next move */
  75.       if(Sick) Sick = 0;
  76.       break;
  77.    case POT_PARALYSIS:
  78.         if(Levitation)
  79.             pline("Your head is frozen to the ceiling!");
  80.         else
  81.             pline("Your feet are frozen to the floor!");
  82.         nomul(-(rn1(10,25)));
  83.         break;
  84.    case POT_MONSTER_DETECTION:
  85.       if(!fmon) {
  86.          strange_feeling(otmp);
  87.          return(1);
  88.       } else {
  89.          cls();
  90.          for(mtmp = fmon; mtmp; mtmp = mtmp->nmon)
  91.             if(mtmp->mx > 0)
  92.             at(mtmp->mx,mtmp->my,mtmp->data->mlet);
  93.          prme();
  94.          pline("You sense the presence of monsters.");
  95.          more();
  96.          docrt();
  97.       }
  98.       break;
  99.    case POT_OBJECT_DETECTION:
  100.       if(!fobj) {
  101.          strange_feeling(otmp);
  102.          return(1);
  103.       } else {
  104.           for(objs = fobj; objs; objs = objs->nobj)
  105.          if(objs->ox != u.ux || objs->oy != u.uy)
  106.             goto outobjmap;
  107.           pline("You sense the presence of objects close nearby.");
  108.           break;
  109.       outobjmap:
  110.          cls();
  111.          for(objs = fobj; objs; objs = objs->nobj)
  112.             at(objs->ox,objs->oy,objs->olet);
  113.          prme();
  114.          pline("You sense the presence of objects.");
  115.          more();
  116.          docrt();
  117.       }
  118.       break;
  119.    case POT_SICKNESS:
  120.       pline("Yech! This stuff tastes like poison.");
  121.       if(Poison_resistance)
  122.     pline("(But in fact it was biologically contaminated orange juice.)");
  123.       losestr(rn1(4,3));
  124.       losehp(rnd(10), "poison potion");
  125.       break;
  126.    case POT_CONFUSION:
  127.       if(!Confusion)
  128.          pline("Huh, What?  Where am I?");
  129.       else
  130.          nothing++;
  131.       Confusion += rn1(7,16);
  132.       break;
  133.    case POT_GAIN_STRENGTH:
  134.       pline("Wow do you feel strong!");
  135.       if(u.ustr == 118) break;
  136.       if(u.ustr > 17) u.ustr += rnd(118-u.ustr);
  137.       else u.ustr++;
  138.       if(u.ustr > u.ustrmax) u.ustrmax = u.ustr;
  139.       flags.botl = 1;
  140.       break;
  141.    case POT_SPEED:
  142.       if(Wounded_legs) {
  143.          if((Wounded_legs & BOTH_SIDES) == BOTH_SIDES)
  144.             pline("Your legs feel somewhat better.");
  145.          else
  146.             pline("Your leg feels somewhat better.");
  147.          Wounded_legs = 0;
  148.          unkn++;
  149.          break;
  150.       }
  151.       if(!(Fast & ~INTRINSIC))
  152.          pline("You are suddenly moving much faster.");
  153.       else
  154.          pline("Your legs get new energy."), unkn++;
  155.       Fast += rn1(10,100);
  156.       break;
  157.    case POT_BLINDNESS:
  158.       if(!Blind)
  159.          pline("A cloud of darkness falls upon you.");
  160.       else
  161.          nothing++;
  162.       Blind += rn1(100,250);
  163.       seeoff(0);
  164.       break;
  165.    case POT_GAIN_LEVEL:
  166.       pluslvl();
  167.       break;
  168.    case POT_EXTRA_HEALING:
  169.       pline("You feel much better.");
  170.       flags.botl = 1;
  171.       u.uhp += d(2,20)+1;
  172.       if(u.uhp > u.uhpmax)
  173.          u.uhp = (u.uhpmax += 2);
  174.       if(Blind) Blind = 1;
  175.       if(Sick) Sick = 0;
  176.       break;
  177.    case POT_LEVITATION:
  178.       if(!Levitation)
  179.          float_up();
  180.       else
  181.          nothing++;
  182.       Levitation += rnd(100);
  183.       u.uprops[PROP(RIN_LEVITATION)].p_tofn = float_down;
  184.       break;
  185.    default:
  186.       pline("What a funny potion! (%d)", otmp->otyp);
  187.       impossible();
  188.       return(0);
  189.    }
  190.    if(nothing) {
  191.        unkn++;
  192.        pline("You have a peculiar feeling for a moment, then it passes.");
  193.    }
  194.    if(otmp->dknown && !objects[otmp->otyp].oc_name_known) {
  195.       if(!unkn) {
  196.          objects[otmp->otyp].oc_name_known = 1;
  197.          u.urexp += 10;
  198.       } else if(!objects[otmp->otyp].oc_uname)
  199.          docall(otmp);
  200.    }
  201.    useup(otmp);
  202.    return(1);
  203. }
  204.  
  205. pluslvl()
  206. {
  207.    register int num;
  208.  
  209.    pline("You feel more experienced.");
  210.    num = rnd(10);
  211.    u.uhpmax += num;
  212.    u.uhp += num;
  213.    u.uexp = (10*pow(u.ulevel-1))+1;
  214.    pline("Welcome to level %d.", ++u.ulevel);
  215.    flags.botl = 1;
  216. }
  217.  
  218. strange_feeling(obj)
  219. register struct obj *obj;
  220. {
  221.    pline("You have a strange feeling for a moment, then it passes.");
  222.    if(!objects[obj->otyp].oc_name_known && !objects[obj->otyp].oc_uname)
  223.       docall(obj);
  224.    useup(obj);
  225. }
  226.  
  227. dodrop() {
  228.    register struct obj *obj;
  229.  
  230.    obj = getobj("0$#", "drop");
  231.    if(!obj) return(0);
  232.    if(obj->olet == '$') {
  233.       if(obj->quan == 0)
  234.          pline("You didn't drop any gold pieces.");
  235.       else {
  236.          mkgold((int) obj->quan, u.ux, u.uy);
  237.          pline("You dropped %u gold piece%s.",
  238.             obj->quan, plur(obj->quan));
  239.          if(Invis) newsym(u.ux, u.uy);
  240.       }
  241.       free((char *) obj);
  242.       return(1);
  243.    }
  244.    return(drop(obj));
  245. }
  246.  
  247. drop(obj) register struct obj *obj; {
  248.    if(obj->owornmask & (W_ARMOR | W_RING)){
  249.       pline("You cannot drop something you are wearing.");
  250.       return(0);
  251.    }
  252.    if(obj == uwep) {
  253.       if(uwep->cursed) {
  254.          pline("Your weapon is welded to your hand!");
  255.          return(0);
  256.       }
  257.       setuwep((struct obj *) 0);
  258.    }
  259.    pline("You dropped %s.", doname(obj));
  260.    dropx(obj);
  261.    return(1);
  262. }
  263.  
  264. dropx(obj) register struct obj *obj; {
  265.    if(obj->otyp == CRYSKNIFE)
  266.       obj->otyp = WORM_TOOTH;
  267.    freeinv(obj);
  268.    obj->ox = u.ux;
  269.    obj->oy = u.uy;
  270.    obj->nobj = fobj;
  271.    fobj = obj;
  272.    if(Invis) newsym(u.ux,u.uy);
  273.    subfrombill(obj);
  274.    stackobj(obj);
  275. }
  276.  
  277. /* drop several things */
  278. doddrop() {
  279.    return(ggetobj("drop", drop, 0));
  280. }
  281.  
  282. rhack(cmd)
  283. register char *cmd;
  284. {
  285.    register struct func_tab *tlist = list;
  286.    boolean firsttime = FALSE;
  287.    register int res;
  288.  
  289.    if(!cmd) {
  290.       firsttime = TRUE;
  291.       flags.nopick = 0;
  292.       cmd = parse();
  293.    }
  294.     if(!*cmd || *cmd == 0377 || (flags.no_rest_on_space && *cmd == ' ')){
  295.         flags.move = 0;
  296.         return;      /* probably we just had an interrupt */
  297.     }
  298.    if(movecm(cmd)) {
  299.    walk:
  300.       if(multi) flags.mv = 1;
  301.       domove();
  302.       return;
  303.    }
  304.    if(movecm(lowc(cmd))) {
  305.       flags.run = 1;
  306.    rush:
  307.       if(firsttime){
  308.          if(!multi) multi = COLNO;
  309.          u.last_str_turn = 0;
  310.       }
  311.       flags.mv = 1;
  312. #ifdef QUEST
  313.       if(flags.run >= 4) finddir();
  314.       if(firsttime){
  315.          u.ux0 = u.ux + u.dx;
  316.          u.uy0 = u.uy + u.dy;
  317.       }
  318. #endif QUEST
  319.       domove();
  320.       return;
  321.    }
  322.    if((*cmd == 'f' && movecm(cmd+1)) ||
  323.       movecm(unctrl(cmd))) {
  324.       flags.run = 2;
  325.       goto rush;
  326.    }
  327.    if(*cmd == 'F' && movecm(lowc(cmd+1))) {
  328.       flags.run = 3;
  329.       goto rush;
  330.    }
  331.    if(*cmd == 'm' && movecm(cmd+1)) {
  332.       flags.run = 0;
  333.       flags.nopick = 1;
  334.       goto walk;
  335.    }
  336.    if(*cmd == 'M' && movecm(lowc(cmd+1))) {
  337.       flags.run = 1;
  338.       flags.nopick = 1;
  339.       goto rush;
  340.    }
  341. #ifdef QUEST
  342.    if(*cmd == cmd[1] && (*cmd == 'f' || *cmd == 'F')) {
  343.       flags.run = 4;
  344.       if(*cmd == 'F') flags.run += 2;
  345.       if(cmd[2] == '-') flags.run += 1;
  346.       goto rush;
  347.    }
  348. #endif QUEST
  349.    while(tlist->f_char) {
  350.       if(*cmd == tlist->f_char){
  351.          res = (*(tlist->f_funct))(0);
  352.          if(!res) {
  353.             flags.move = 0;
  354.             multi = 0;
  355.          }
  356.          return;
  357.       }
  358.       tlist++;
  359.    }
  360.    pline("Unknown command '%s'",cmd);
  361.    multi = flags.move = 0;
  362. }
  363.  
  364. doredraw()
  365. {
  366.    docrt();
  367.    return(0);
  368. }
  369.  
  370. dohelp()
  371. {
  372.     FILE *fp;
  373.     char bufr[BUFSZ];
  374.     int line, i;
  375.     
  376.     if ( (fp = fopen(HELP,"r")) == NULL)
  377.         pline("cannot access help");
  378.     else
  379.         {
  380.         cls();
  381.         line = 1;
  382.         while(fgets(bufr,BUFSZ,fp))
  383.             {
  384.             myprintf("%s", bufr);
  385.             if (line++ > ROWNO)
  386.                 {
  387.                 myprintf("---more---");
  388.                 xwaitforspace(FALSE);
  389.                 morc = 0;
  390.                 for (i=0;i<10;i++)
  391.                     backsp();
  392.                 cl_end();
  393.                 line = 1;
  394.                 }
  395.             }
  396.         more();
  397.         docrt();
  398.         }
  399. }
  400.  
  401. #ifdef SHELL
  402. dosh(){
  403.    char *file, *Open();
  404.    if ( (file = Open("CON:1/1/639/199/Hack SubProcess", 1006)) == NULL)
  405.     pline("cannot create process window");
  406.    if (Execute("", file, NULL))
  407.       pline("cannot execute commands");
  408.    Close(file);
  409.    return(0);
  410. }
  411. #endif SHELL
  412.  
  413. child(wt) {
  414.    pline("Cannot create children");
  415.    docrt();
  416.    return(0);
  417. }
  418.  
  419. dodown()
  420. {
  421.    if(u.ux != xdnstair || u.uy != ydnstair) {
  422.       pline("You can't go down here.");
  423.       return(0);
  424.    }
  425.    if(u.ustuck) {
  426.       pline("You are being held, and cannot go down.");
  427.       return(1);
  428.    }
  429.    if(Levitation) {
  430.       pline("You're floating high above the stairs.");
  431.       return(0);
  432.    }
  433.  
  434.    goto_level(dlevel+1, TRUE);
  435.    return(1);
  436. }
  437.  
  438. doup()
  439. {
  440.    if(u.ux != xupstair || u.uy != yupstair) {
  441.       pline("You can't go up here.");
  442.       return(0);
  443.    }
  444.    if(u.ustuck) {
  445.       pline("You are being held, and cannot go up.");
  446.       return(1);
  447.    }
  448.    if(inv_weight() + 5 > 0) {
  449.       pline("Your load is too heavy to climb the stairs.");
  450.       return(1);
  451.    }
  452.  
  453.    goto_level(dlevel-1, TRUE);
  454.    return(1);
  455. }
  456.  
  457. goto_level(newlevel, at_stairs)
  458. register int newlevel;
  459. register boolean at_stairs;
  460. {
  461.    register int fd;
  462.    register boolean up = (newlevel < dlevel);
  463.  
  464.     if(newlevel <= 0) done("escaped");    /* in fact < 0 is impossible */
  465.     if(newlevel == dlevel) return;          /* this cannot happen either */
  466.  
  467.    glo(dlevel);
  468.    fd = creat(lock,FMASK);
  469.    if(fd < 0) {
  470.       /*
  471.        * This is not quite impossible: e.g., we may have
  472.        * exceeded our quota. If that is the case then we
  473.        * cannot leave this level, and cannot save either.
  474.        */
  475.       pline("A mysterious force prevents you from going %s.",
  476.          up ? "up" : "down");
  477.       return;
  478.    }
  479.  
  480.    if(Punished) unplacebc();
  481.    keepdogs();
  482.    seeoff(1);
  483.    flags.nscrinh = 1;
  484.    u.ux = FAR;            /* hack */
  485.    (void) inshop();         /* probably was a trapdoor */
  486.  
  487.    savelev(fd);
  488.    (void) close(fd);
  489.  
  490.    dlevel = newlevel;
  491.    if(maxdlevel < dlevel)
  492.       maxdlevel = dlevel;
  493.    glo(dlevel);
  494.    if((fd = open(lock,0)) < 0)
  495.       mklev();
  496.    else {
  497.       (void) getlev(fd);
  498.       (void) close(fd);
  499.    }
  500.  
  501.    if(at_stairs) {
  502.        if(up) {
  503.       u.ux = xdnstair;
  504.       u.uy = ydnstair;
  505.       if(!u.ux) {      /* entering a maze from below? */
  506.           u.ux = xupstair;   /* this will confuse the player! */
  507.           u.uy = yupstair;
  508.       }
  509.       if(Punished){
  510.          pline("With great effort you climb the stairs");
  511.          placebc(1);
  512.       }
  513.        } else {
  514.       u.ux = xupstair;
  515.       u.uy = yupstair;
  516.       if(inv_weight() + 5 > 0 || Punished){
  517.          pline("You fall down the stairs.");
  518.          losehp(rnd(3), "fall");
  519.          if(Punished) {
  520.              if(uwep != uball && rn2(3)){
  521.             pline("... and are hit by the iron ball");
  522.             losehp(rnd(20), "iron ball");
  523.              }
  524.              placebc(1);
  525.          }
  526.          selftouch("Falling, you");
  527.       }
  528.        }
  529.    } else {   /* trapdoor or level_tele */
  530.        do {
  531.       u.ux = rnd(COLNO-1);
  532.       u.uy = rn2(ROWNO);
  533.        } while(levl[u.ux][u.uy].typ != ROOM ||
  534.          m_at(u.ux,u.uy));
  535.        if(Punished){
  536.       if(uwep != uball && !up /* %% */ && rn2(5)){
  537.          pline("The iron ball falls on your head.");
  538.          losehp(rnd(25), "iron ball");
  539.       }
  540.       placebc(1);
  541.        }
  542.        selftouch("Falling, you");
  543.    }
  544.    (void) inshop();
  545. #ifdef TRACK
  546.    initrack();
  547. #endif TRACK
  548.  
  549.    losedogs();
  550.    flags.nscrinh = 0;
  551.    setsee();
  552.     { register struct monst *mtmp;
  553.       if(mtmp = m_at(u.ux, u.uy)) mnexto(mtmp);    /* riv05!a3 */
  554.     }
  555.    docrt();
  556.    pickup();
  557.    read_engr_at(u.ux,u.uy);
  558. }
  559.  
  560. donull() {
  561.    return(1);   /* Do nothing, but let other things happen */
  562. }
  563.  
  564. struct monst *bhit(), *boomhit();
  565. dothrow()
  566. {
  567.    register struct obj *obj;
  568.    register struct monst *mon;
  569.    register int tmp;
  570.  
  571.     obj = getobj("#)", "throw");   /* it is also possible to throw food */
  572.                        /* (or jewels, or iron balls ... ) */
  573.    if(!obj || !getdir())
  574.       return(0);
  575.    if(obj->owornmask & (W_ARMOR | W_RING)){
  576.       pline("You can't throw something you are wearing");
  577.       return(0);
  578.    }
  579.    if(obj == uwep){
  580.       if(obj->cursed){
  581.          pline("Your weapon is welded to your hand");
  582.          return(1);
  583.       }
  584.       if(obj->quan > 1)
  585.          setuwep(splitobj(obj, 1));
  586.       else
  587.          setuwep((struct obj *) 0);
  588.    }
  589.    else if(obj->quan > 1)
  590.       (void) splitobj(obj, 1);
  591.    freeinv(obj);
  592.    if(u.uswallow) {
  593.       mon = u.ustuck;
  594.       bhitpos.x = mon->mx;
  595.       bhitpos.y = mon->my;
  596.    } else if(obj->otyp == BOOMERANG) {
  597.       mon = boomhit(u.dx,u.dy);
  598.       /* boomhit delivers -1 if the thing was caught */
  599.       if((int) mon == -1) {
  600.          (void) addinv(obj);
  601.          return(1);
  602.       }
  603.    } else
  604.       mon = bhit(u.dx,u.dy,
  605.          (!Punished || obj != uball) ? 8 :
  606.             !u.ustuck ? 5 : 1,
  607.          obj->olet);
  608.    if(mon) {
  609.       /* awake monster if sleeping */
  610.       wakeup(mon);
  611.  
  612.       if(obj->olet == WEAPON_SYM) {
  613.          tmp = -1+u.ulevel+mon->data->ac+abon();
  614.          if(obj->otyp < ROCK) {
  615.             if(!uwep ||
  616.                 uwep->otyp != obj->otyp+(BOW-ARROW))
  617.                tmp -= 4;
  618.             else {
  619.                tmp += uwep->spe;
  620.             }
  621.          } else
  622.          if(obj->otyp == BOOMERANG) tmp += 4;
  623.          tmp += obj->spe;
  624.          if(u.uswallow || tmp >= rnd(20)) {
  625.             if(hmon(mon,obj,1) == TRUE){
  626.               /* mon still alive */
  627. #ifndef NOWORM
  628.               cutworm(mon,bhitpos.x,bhitpos.y,obj->otyp);
  629. #endif NOWORM
  630.             } else mon = 0;
  631.             /* weapons thrown disappear sometimes */
  632.             if(obj->otyp < BOOMERANG && rn2(3)) {
  633.                /* check bill; free */
  634.                obfree(obj, (struct obj *) 0);
  635.                return(1);
  636.             }
  637.          } else miss(objects[obj->otyp].oc_name, mon);
  638.       } else if(obj->otyp == HEAVY_IRON_BALL) {
  639.          tmp = -1+u.ulevel+mon->data->ac+abon();
  640.          if(!Punished || obj != uball) tmp += 2;
  641.          if(u.utrap) tmp -= 2;
  642.          if(u.uswallow || tmp >= rnd(20)) {
  643.             if(hmon(mon,obj,1) == FALSE)
  644.                mon = 0;   /* he died */
  645.          } else miss("iron ball", mon);
  646.       } else {
  647.          if(cansee(bhitpos.x,bhitpos.y))
  648.             pline("You miss %s.",monnam(mon));
  649.          else pline("You miss it.");
  650.          if(obj->olet == FOOD_SYM && mon->data->mlet == 'd')
  651.             if(tamedog(mon,obj)) return(1);
  652.          if(obj->olet == GEM_SYM && mon->data->mlet == 'u'){
  653.           if(obj->dknown && objects[obj->otyp].oc_name_known){
  654.            if(objects[obj->otyp].g_val > 0){
  655.              u.uluck += 5;
  656.              goto valuable;
  657.            } else {
  658.              pline("%s is not interested in your junk.",
  659.             Monnam(mon));
  660.            }
  661.           } else { /* value unknown to @ */
  662.              u.uluck++;
  663.          valuable:
  664.              pline("%s graciously accepts your gift.",
  665.             Monnam(mon));
  666.              mpickobj(mon, obj);
  667.              rloc(mon);
  668.              return(1);
  669.           }
  670.          }
  671.       }
  672.    }
  673.    obj->ox = bhitpos.x;
  674.    obj->oy = bhitpos.y;
  675.    obj->nobj = fobj;
  676.    fobj = obj;
  677.    /* prevent him from throwing articles to the exit and escaping */
  678.    /* subfrombill(obj); */
  679.    stackobj(obj);
  680.    if(Punished && obj == uball &&
  681.       (bhitpos.x != u.ux || bhitpos.y != u.uy)){
  682.       freeobj(uchain);
  683.       unpobj(uchain);
  684.       if(u.utrap){
  685.          if(u.utraptype == TT_PIT)
  686.             pline("The ball pulls you out of the pit!");
  687.          else {
  688.              register long side =
  689.             rn2(3) ? LEFT_SIDE : RIGHT_SIDE;
  690.              pline("The ball pulls you out of the bear trap.");
  691.              pline("Your %s leg is severely damaged.",
  692.             (side == LEFT_SIDE) ? "left" : "right");
  693.              Wounded_legs |= side + rnd(1000);
  694.              losehp(2, "thrown ball");
  695.          }
  696.          u.utrap = 0;
  697.       }
  698.       unsee();
  699.       uchain->nobj = fobj;
  700.       fobj = uchain;
  701.       u.ux = uchain->ox = bhitpos.x - u.dx;
  702.       u.uy = uchain->oy = bhitpos.y - u.dy;
  703.       setsee();
  704.       (void) inshop();
  705.    }
  706.    if(cansee(bhitpos.x, bhitpos.y)) prl(bhitpos.x,bhitpos.y);
  707.    return(1);
  708. }
  709.  
  710. /* split obj so that it gets size num */
  711. /* remainder is put in the object structure delivered by this call */
  712. struct obj *
  713. splitobj(obj, num) register struct obj *obj; register int num; {
  714. register struct obj *otmp;
  715.    otmp = newobj(0);
  716.    *otmp = *obj;      /* copies whole structure */
  717.    otmp->o_id = flags.ident++;
  718.    otmp->onamelth = 0;
  719.    obj->quan = num;
  720.    obj->owt = weight(obj);
  721.    otmp->quan -= num;
  722.    otmp->owt = weight(otmp);   /* -= obj->owt ? */
  723.    obj->nobj = otmp;
  724.    if(obj->unpaid) splitbill(obj,otmp);
  725.    return(otmp);
  726. }
  727.  
  728. char *
  729. lowc(str)
  730. register char *str;
  731. {
  732.    static char buf[2];
  733.  
  734.    if(*str >= 'A' && *str <= 'Z') *buf = *str+'a'-'A';
  735.    else *buf = *str;
  736.    buf[1] = 0;
  737.    return(buf);
  738. }
  739.  
  740. char *
  741. unctrl(str)
  742. register char *str;
  743. {
  744.    static char buf[2];
  745.    if(*str >= ('A' & 037) && *str <= ('Z' & 037))
  746.       *buf = *str + 0140;
  747.    else *buf = *str;
  748.    buf[1] = 0;
  749.    return(buf);
  750. }
  751.  
  752.